<?php
/*
 * Created on 2008-1-22
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 include("lib_user.php");
 include("ref_config.php");
 $ref_host="127.0.0.1";
 $ref_username="level-4-username";
 $ref_password="level-4-password";
 $developer=true;
 class official_action
 	{
 		private $level_5_username,$level_5_password;
 		function official_action($level_5_username,$level_5_password)
 		{
 			global $developer;
 			$this->level_5_username=$level_5_username;
 			$this->level_5_password=$level_5_password;
 			if($developer)
 				echo("官方动作对象成功建立");
 		}
 		
 		function certificate_user_realname($user)
 		{
 			global $ref_host;
			global $ref_username;
			global $ref_password,$ref_basename;
			global $developer;
			$ref_link=mysql_connect($ref_host,$this->level_5_username,$this->level_5_password);
			mysql_select_db($ref_basename,$ref_link);	
			if ($ref_link!=FALSE)
			{
				$select_format='SELECT user_rec_ID FROM certification WHERE epsn="%s" AND user_ID=%d';
				$query=sprintf($select_format,$user->epsn,$user->user_ID);
				if($developer)
				print($query."<br />");
				$res_user=mysql_query($query,$ref_link);
				if($obj_user=mysql_fetch_object($res_user))
				{
					$update_format='UPDATE certification SET level=1 WHERE user_rec_ID=%d';
					$query=sprintf($update_format,$obj_user->user_rec_ID);
					if($developer)
						echo("实名认证:".$query."<br />");
					$res_nouse=mysql_query($query,$ref_link);
					if($developer)
						echo("实名认证:用户".$user->username."已通过实名认证<br />");
				}
				else
				{
					$insert_format='INSERT INTO certification (epsn,user_ID,level) VALUE ("%s",%d,1)';
					$query=sprintf($insert_format,$user->epsn,$user->user_ID);
					if($developer)
						echo("实名认证:".$query."<br />");
					$res_nouse=mysql_query($query,$ref_link);
					if($developer)
						echo("实名认证:用户".$user->username."已通过实名认证<br />");
				}
				mysql_close($ref_link);
			}
 		}
 		
 		function certificate_user_diploma($user)
 		{
 			global $ref_host;
			global $ref_username;
			global $ref_password,$ref_basename;
			global $developer;
			$ref_link=mysql_connect($ref_host,$this->level_5_username,$this->level_5_password);
			mysql_select_db($ref_basename,$ref_link);	
			if ($ref_link!=FALSE)
			{
				$select_format='SELECT user_rec_ID FROM certification WHERE epsn="%s" AND user_ID=%d';
				$query=sprintf($select_format,$user->epsn,$user->user_ID);
				if($developer)
				print($query."<br />");
				$res_user=mysql_query($query,$ref_link);
				if($obj_user=mysql_fetch_object($res_user))
				{
					$update_format='UPDATE certification SET level=2 WHERE user_rec_ID=%d';
					$query=sprintf($update_format,$obj_user->user_rec_ID);
					if($developer)
						echo("实名认证:".$query."<br />");
					$res_nouse=mysql_query($query,$ref_link);
					if($developer)
						echo("实名认证:用户".$user->username."已通过实名认证<br />");
				}
				else
				{
					$insert_format='INSERT INTO certification (epsn,user_ID,level) VALUE ("%s",%d,2)';
					$query=sprintf($insert_format,$user->epsn,$user->user_ID);
					if($developer)
						echo("实名认证:".$query."<br />");
					$res_nouse=mysql_query($query,$ref_link);
					if($developer)
						echo("实名认证:用户".$user->username."已通过实名认证<br />");
				}
				mysql_close($ref_link);
			}
 		}
 	}


?>
